package com.xyh.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {
    public static String YYYY_MM_DD ="yyyy-MM-dd";
    public static String YYYY_MM_DD_HH_MM_SS ="yyyy-MM-dd HH:mm:ss";
    public static String YYYY_MM_DD_HH_MM ="yyyy-MM-dd HH:mm";
    public static String YYYYMMDD ="yyyyMMdd";
    public static String YYYYMMDDHHMMSS ="yyyyMMddHHmmss";
    public static String YYYYMMDDHHMM ="yyyyMMddHHmm";
    public static String YYYYMMDDHH ="yyyyMMddHH";
    public static String YYYY ="yyyy";
    public static String format(Date date,String pattern){
        return new SimpleDateFormat(pattern).format(date);
    }
    public static Date parse(String date,String pattern){
        try {
            return new SimpleDateFormat(pattern).parse(date);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }

}
